
#include "ili9341_lcd.h"
#include "gui.h"
#include "test.h"
#include "soc_osal.h"
#include "pic.h"

//========================variable==========================//
uint16_t ColorTab[5] = {RED, GREEN, BLUE, YELLOW, BRED}; // ������ɫ����
//=====================end of variable======================//

/*****************************************************************************
 * @name       :void DrawTestPage(uint8_t *str)
 * @date       :2018-08-09
 * @function   :Drawing test interface
 * @parameters :str:the start address of the Chinese and English strings
 * @retvalue   :None
 ******************************************************************************/
void DrawTestPage(uint8_t *str)
{
    // ���ƹ̶���up
    LCD_Clear(WHITE);
    LCD_Fill(0, 0, lcddev.width, 20, BLUE);
    // ���ƹ̶���down
    LCD_Fill(0, lcddev.height - 20, lcddev.width, lcddev.height, BLUE);
    POINT_COLOR = WHITE;
    Gui_StrCenter(0, 2, WHITE, BLUE, str, 16, 1);                                       // ������ʾ
    Gui_StrCenter(0, lcddev.height - 18, WHITE, BLUE, "http://www.lcdwiki.com", 16, 1); // ������ʾ
    // ���Ʋ�������
    // LCD_Fill(0,20,lcddev.width,lcddev.height-20,WHITE);
}

/*****************************************************************************
 * @name       :void main_test(void)
 * @date       :2018-08-09
 * @function   :Drawing the main Interface of the Comprehensive Test Program
 * @parameters :None
 * @retvalue   :None
 ******************************************************************************/
void main_test(void)
{
    DrawTestPage("�ۺϲ��Գ���");
    Gui_StrCenter(0, 30, RED, BLUE, "���ֿ��Ƽ�", 16, 1);                 // ������ʾ
    Gui_StrCenter(0, 60, RED, BLUE, "�ۺϲ��Գ���", 16, 1);               // ������ʾ
    Gui_StrCenter(0, 90, GREEN, BLUE, "3.2\" ILI9341 240X320", 16, 1); // ������ʾ
    Gui_StrCenter(0, 120, BLUE, BLUE, "www.wlklcd.com", 16, 1);        // ������ʾ
    osal_msleep(1500);
    osal_msleep(1500);
}

/*****************************************************************************
 * @name       :void Test_Color(void)
 * @date       :2018-08-09
 * @function   :Color fill test(white,black,red,green,blue)
 * @parameters :None
 * @retvalue   :None
 ******************************************************************************/
void Test_Color(void)
{
    // DrawTestPage("����1:��ɫ������");
    LCD_Fill(0, 0, lcddev.width, lcddev.height, WHITE);
    Show_Str(20, 30, BLUE, YELLOW, "BL Test", 16, 1);
    osal_msleep(800);
    LCD_Fill(0, 0, lcddev.width, lcddev.height, RED);
    Show_Str(20, 30, BLUE, YELLOW, "RED ", 16, 1);
    osal_msleep(800);
    LCD_Fill(0, 0, lcddev.width, lcddev.height, GREEN);
    Show_Str(20, 30, BLUE, YELLOW, "GREEN ", 16, 1);
    osal_msleep(800);
    LCD_Fill(0, 0, lcddev.width, lcddev.height, BLUE);
    Show_Str(20, 30, RED, YELLOW, "BLUE ", 16, 1);
    osal_msleep(800);
}

/*****************************************************************************
 * @name       :void Test_FillRec(void)
 * @date       :2018-08-09
 * @function   :Rectangular display and fill test
                                Display red,green,blue,yellow,pink rectangular boxes in turn,
                                1500 milliseconds later,
                                Fill the rectangle in red,green,blue,yellow and pink in turn
 * @parameters :None
 * @retvalue   :None
******************************************************************************/
void Test_FillRec(void)
{
    uint8_t i = 0;
    DrawTestPage("����2:GUI����������");
    LCD_Fill(0, 20, lcddev.width, lcddev.height - 20, WHITE);
    for (i = 0; i < 5; i++) {
        POINT_COLOR = ColorTab[i];
        LCD_DrawRectangle(lcddev.width / 2 - 80 + (i * 15), lcddev.height / 2 - 80 + (i * 15),
                          lcddev.width / 2 - 80 + (i * 15) + 60, lcddev.height / 2 - 80 + (i * 15) + 60);
    }
    osal_msleep(1500);
    LCD_Fill(0, 20, lcddev.width, lcddev.height - 20, WHITE);
    for (i = 0; i < 5; i++) {
        POINT_COLOR = ColorTab[i];
        LCD_DrawFillRectangle(lcddev.width / 2 - 80 + (i * 15), lcddev.height / 2 - 80 + (i * 15),
                              lcddev.width / 2 - 80 + (i * 15) + 60, lcddev.height / 2 - 80 + (i * 15) + 60);
    }
    osal_msleep(1500);
}

/*****************************************************************************
 * @name       :void Test_Circle(void)
 * @date       :2018-08-09
 * @function   :circular display and fill test
                                Display red,green,blue,yellow,pink circular boxes in turn,
                                1500 milliseconds later,
                                Fill the circular in red,green,blue,yellow and pink in turn
 * @parameters :None
 * @retvalue   :None
******************************************************************************/
void Test_Circle(void)
{
    uint8_t i = 0;
    DrawTestPage("����3:GUI��Բ������");
    LCD_Fill(0, 20, lcddev.width, lcddev.height - 20, WHITE);
    for (i = 0; i < 5; i++)
        gui_circle(lcddev.width / 2 - 80 + (i * 25), lcddev.height / 2 - 50 + (i * 25), ColorTab[i], 30, 0);
    osal_msleep(1500);
    LCD_Fill(0, 20, lcddev.width, lcddev.height - 20, WHITE);
    for (i = 0; i < 5; i++)
        gui_circle(lcddev.width / 2 - 80 + (i * 25), lcddev.height / 2 - 50 + (i * 25), ColorTab[i], 30, 1);
    osal_msleep(1500);
}

/*****************************************************************************
 * @name       :void English_Font_test(void)
 * @date       :2018-08-09
 * @function   :English display test
 * @parameters :None
 * @retvalue   :None
 ******************************************************************************/
void English_Font_test(void)
{
    DrawTestPage("����5:Ӣ����ʾ����");
    Show_Str(10, 30, BLUE, YELLOW, "6X12:abcdefghijklmnopqrstuvwxyz0123456789", 12, 0);
    Show_Str(10, 45, BLUE, YELLOW, "6X12:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 12, 1);
    Show_Str(10, 60, BLUE, YELLOW, "6X12:~!@#$%^&*()_+{}:<>?/|-+.", 12, 0);
    Show_Str(10, 80, BLUE, YELLOW, "8X16:abcdefghijklmnopqrstuvwxyz0123456789", 16, 0);
    Show_Str(10, 100, BLUE, YELLOW, "8X16:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 16, 1);
    Show_Str(10, 120, BLUE, YELLOW, "8X16:~!@#$%^&*()_+{}:<>?/|-+.", 16, 0);
    osal_msleep(1200);
}

/*****************************************************************************
 * @name       :void Test_Triangle(void)
 * @date       :2018-08-09
 * @function   :triangle display and fill test
                                Display red,green,blue,yellow,pink triangle boxes in turn,
                                1500 milliseconds later,
                                Fill the triangle in red,green,blue,yellow and pink in turn
 * @parameters :None
 * @retvalue   :None
******************************************************************************/
void Test_Triangle(void)
{
    uint8_t i = 0;
    DrawTestPage("����4:GUI Triangle������");
    LCD_Fill(0, 20, lcddev.width, lcddev.height - 20, WHITE);
    for (i = 0; i < 5; i++) {
        POINT_COLOR = ColorTab[i];
        Draw_Triangel(lcddev.width / 2 - 80 + (i * 20), lcddev.height / 2 - 20 + (i * 15),
                      lcddev.width / 2 - 50 - 1 + (i * 20), lcddev.height / 2 - 20 - 52 - 1 + (i * 15),
                      lcddev.width / 2 - 20 - 1 + (i * 20), lcddev.height / 2 - 20 + (i * 15));
    }
    osal_msleep(1500);
    LCD_Fill(0, 20, lcddev.width, lcddev.height - 20, WHITE);
    for (i = 0; i < 5; i++) {
        POINT_COLOR = ColorTab[i];
        Fill_Triangel(lcddev.width / 2 - 80 + (i * 20), lcddev.height / 2 - 20 + (i * 15),
                      lcddev.width / 2 - 50 - 1 + (i * 20), lcddev.height / 2 - 20 - 52 - 1 + (i * 15),
                      lcddev.width / 2 - 20 - 1 + (i * 20), lcddev.height / 2 - 20 + (i * 15));
    }
    osal_msleep(1500);
}

/*****************************************************************************
 * @name       :void Chinese_Font_test(void)
 * @date       :2018-08-09
 * @function   :chinese display test
 * @parameters :None
 * @retvalue   :None
 ******************************************************************************/
void Chinese_Font_test(void)
{
    DrawTestPage("����6:������ʾ����");
    Show_Str(10, 30, BLUE, YELLOW, "16X16:���ֿ��Ƽ����޹�˾��ӭ��", 16, 0);
    Show_Str(10, 50, BLUE, YELLOW, "16X16:Welcome���ֿ��Ƽ�", 16, 0);
    Show_Str(10, 70, BLUE, YELLOW, "24X24:���������Ĳ���", 24, 1);
    Show_Str(10, 100, BLUE, YELLOW, "32X32:�������", 32, 1);
    osal_msleep(1200);
}

/*****************************************************************************
 * @name       :void Pic_test(void)
 * @date       :2018-08-09
 * @function   :picture display test
 * @parameters :None
 * @retvalue   :None
 ******************************************************************************/
void Pic_test(void)
{
    DrawTestPage("����7:ͼƬ��ʾ����");
    //LCD_Fill(0,20,lcddev.width,lcddev.height-20,WHITE);
    Gui_Drawbmp16(30, 30, gImage_qq);
    Show_Str(30 + 12, 75, BLUE, YELLOW, "QQ", 16, 1);
    Gui_Drawbmp16(90, 30, gImage_qq);
    Show_Str(90 + 12, 75, BLUE, YELLOW, "QQ", 16, 1);
    Gui_Drawbmp16(150, 30, gImage_qq);
    Show_Str(150 + 12, 75, BLUE, YELLOW, "QQ", 16, 1);
    osal_msleep(1200);
}